package com.yurun.service.impl;

import com.yurun.entity.ExceptionLog;
import com.yurun.exception.PersistenceException;
import com.yurun.mapper.ExceptionLogMapper;
import com.yurun.service.ExceptionLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExceptionLogServiceImpl implements ExceptionLogService{
    @Autowired
    ExceptionLogMapper exceptionLogMapper;

    @Override
    public void addExceptionLog(ExceptionLog exceptionLog){
        if(exceptionLogMapper.addExceptionLog(exceptionLog)!=1){
            throw new PersistenceException("添加错误日志失败");
        }
    }

    @Override
    public void deleteExceptionLogById(Long id){
        if(exceptionLogMapper.deleteExceptionLogById(id)!=1){
            throw new PersistenceException("删除错误日志失败");
        }
    }

    @Override
    public List<ExceptionLog> getExceptionLogListByDate(String startDate, String endDate){
        return getExceptionLogListByDate(startDate, endDate);
    }
}
